package com.xinzhi.savingpot.background.controller;



import com.xinzhi.savingpot.background.service.impl.SystemServiceImpl;
import com.xinzhi.savingpot.background.vo.UserVo;
import com.xinzhi.savingpot.util.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("system")
@Api("系统管理")
public class SystemController {
    @Autowired
    private SystemServiceImpl iSystemService;

    @PostMapping("/addUser")
    @ApiOperation("后台增加管理用户")
    public BaseResponse addAdmin( UserVo userVo) throws Exception {

        return  iSystemService.addAdmin(userVo);
    }


    @GetMapping("/delSystemUser")
    @ApiOperation("后台删除用户")
    public BaseResponse delSystemUser(String username){
        return iSystemService.delSystemUser(username);
    }



    @GetMapping("/changeSystemUser")
    @ApiOperation("修改系统用户信息")
    public BaseResponse changeSystemUser(UserVo user){
        return iSystemService.changeSystemUser(user);
    }

    @GetMapping("/querySystemUser")
    @ApiOperation("查询系统用户")
    public BaseResponse querySystemUser(){
        return iSystemService.querySystemUser();
    }

    @GetMapping("/queryPage")
    @ApiOperation("分页查询系统用户")
    public BaseResponse queryPage(@RequestParam("index") String index){
        return iSystemService.queryPage(index);
    }

    @GetMapping("/queryGroup")
    @ApiOperation("分页分组查询系统用户")
    public BaseResponse queryGroup(@RequestParam("userrole")String suserrole,@RequestParam("index") String index){
        return iSystemService.queryGroup(suserrole,index);
    }

}
